package com.example.springframeworklearning.propertyeditor;

import java.beans.PropertyEditorSupport;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * 将指定格式的字符串 解析为 LocalDateTime 对象
 * @author luo
 * @since 2022/9/19 15:44
 */
public class LocalDateTimePropertyEditor extends PropertyEditorSupport {


    @Override
    public void setAsText(String text) throws IllegalArgumentException {

        super.setValue(LocalDateTime.of(LocalDate.parse(text,DateTimeFormatter.ofPattern("yyyyMMdd")), LocalTime.MIN));
    }
}
